***********************************************************************************
* THE LOSER'S LONG CURSE: HOW EXPOSURE TO CLASS CONFLICT SHAPES ELECTION OUTCOMES *
***********************************************************************************

* This file reproduces the following tables and figures in our manuscript:
* Tables 1-5 and Figures 2-3.

********************************************************************************

* Set up working folders --- NB. Replace these with your own paths!

global data " "
global tables " "
global figures " "

********************************************************************************

* Open the data set

use "$data/MM_data_main.dta", clear

********************************************************************************

* Table 1

gen post = 0
replace post = 1 if year>1916

est clear

reg red_parties c.dead##i.post i.munig i.year, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.dead##i.post, absorb(munig year) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.insurgency##i.post i.munig i.year, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.insurgency##i.post, absorb(munig year) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.whitedead##i.post i.munig i.year, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.whitedead##i.post, absorb(munig year) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.dead##i.post i.munig i.year if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.dead##i.post if red_region == 1, absorb(munig year) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.insurgency##i.post i.munig i.year if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.insurgency##i.post if red_region == 1, absorb(munig year) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.whitedead##i.post i.munig i.year if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.whitedead##i.post if red_region == 1, absorb(munig year) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.dead##i.post i.munig i.year if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.dead##i.post if red_region == 0, absorb(munig year) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.insurgency##i.post i.munig i.year if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.insurgency##i.post if red_region == 0, absorb(munig year) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.whitedead##i.post i.munig i.year if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.whitedead##i.post if red_region == 0, absorb(munig year) vce(cluster munig)
estadd scalar beta
estadd ysumm

esttab est* using "$tables/table_1.tex", replace  mgroups("Entire country" "Red Finland" "White Finland",  pattern(1 0 0 1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) )  booktabs   ///
	compress lines star(* .1 ** .05 *** .01) ///
	b(%9.3f) se(%9.3f) stats(N r2 ymean beta, labels("\textit{N}"  "\textit{R\textsuperscript{2}}" "Outcome mean" "Standardized effect size") ///
	fmt(0 2 2 2)) keep(1.post#c.dead 1.post#c.insurgency 1.post#c.whitedead) coeflabels(1.post#c.dead "Civil war casualties $\times$ 1[Year $\geq$ 1917]" ///
	1.post#c.insurgency "Red casualties $\times$ 1[Year $\geq$ 1917]" 1.post#c.whitedead "White casualties $\times$ 1[Year $\geq$ 1917]") nodepvars nomtitle ///
	prehead(\begin{tabular}{l*{10}{c}} \toprule) refcat(1.post#c.dead "\textbf{Panel A:} No controls", nolabel) ///
	postfoot("")
	
est clear

reg red_parties c.dead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.dead##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.insurgency##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.insurgency##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.whitedead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.whitedead##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.dead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.dead##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.insurgency##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.insurgency##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.whitedead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.whitedead##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.dead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.dead##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.insurgency##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.insurgency##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.whitedead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.whitedead##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

esttab est* using "$tables/table_1.tex", append  booktabs   ///
	compress lines star(* .1 ** .05 *** .01) ///
	b(%9.3f) se(%9.3f) stats(N r2 ymean beta, labels("\textit{N}"  "\textit{R\textsuperscript{2}}" "Outcome mean" "Standardized effect size") ///
	fmt(0 2 2 2)) keep(1.post#c.dead 1.post#c.insurgency 1.post#c.whitedead) coeflabels(1.post#c.dead "Civil war casualties $\times$ 1[Year $\geq$ 1917]" ///
	1.post#c.insurgency "Red casualties $\times$ 1[Year $\geq$ 1917]" 1.post#c.whitedead "White casualties $\times$ 1[Year $\geq$ 1917]") nodepvars nomtitle nonumbers ///
	prehead("") refcat(1.post#c.dead "\textbf{Panel B:} Controls included", nolabel) ///
	postfoot(\bottomrule \end{tabular})

********************************************************************************

* Figure 2
	
levelsof year, local(level)
foreach l of local level {
		gen treat_`l'=0
		replace treat_`l'=dead if year==`l'
	}

tempfile t1 t2
parmby "reghdfe red_parties treat_1910 treat_1911 treat_1913 treat_1917 treat_1919 treat_1922 treat_1924 treat_1927 treat_1929 treat_1930 treat_1933 treat_1936, a(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)", lab saving(`"`t1'"',replace) idn(1) ids(Unadjusted)

preserve
clear all
set obs 1
gen year =1916
gen estimate = 0
gen parm ="treat_1916"
gen min95 =0
gen max95 =0
append using `t1'
keep if regexm(parm, "^treat*")
gen yearstr =substr(parm, -4,4)
destring yearstr, replace
sort yearstr

twoway  (rcap min95 max95 yearstr, lwidth(medium) ylabel(,format(%9.0f)) scheme(plotplain) xsize(6) ysize(4) xtitle(Year, size(small))  yline(0, lcolor(black)) xline(1916.5, lcolor(black))  xline(1918, lcolor(black)) ytitle(Regression coefficient) ///
xlabel(1910 1911 1913 1916 1917 1919 1922 1924 1927 1929 1930 1933 1936, angle(vertical) labsize(small)) graphregion(color(white)) legend(off)) (connected estimate yearstr, msize(medium) msymbol(circle) mcolor(black))

graph export "$figures/figure_2.pdf", as(pdf) replace
	
restore		
	
********************************************************************************

* Table 2

est clear

reg red_parties c.battle_red_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.battle_red_share##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.battle_white_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.battle_white_share##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.battle_red_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.battle_red_share##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.battle_white_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.battle_white_share##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.battle_red_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.battle_red_share##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.battle_white_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.battle_white_share##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

esttab est* using "$tables/table_2.tex", replace  mgroups("Entire country" "Red Finland" "White Finland",  pattern(1 0 1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) )  booktabs   ///
	compress lines star(* .1 ** .05 *** .01) ///
	b(%9.3f) se(%9.3f) stats(N r2 ymean beta, labels("\textit{N}"  "\textit{R\textsuperscript{2}}" "Outcome mean" "Standardized effect size") ///
	fmt(0 2 2 2)) keep(1.post#c.battle_red_share 1.post#c.battle_white_share) coeflabels(1.post#c.battle_red_share "Red battle casualties $\times$ 1[Year $\geq$ 1917]" ///
	1.post#c.battle_white_share "White battle casualties $\times$ 1[Year $\geq$ 1917]") nodepvars nomtitle ///
	prehead(\begin{tabular}{l*{7}{c}} \toprule) refcat(1.post#c.battle_red_share "\textbf{Panel A:} Battle casualties", nolabel) ///
	postfoot("")		
	
est clear

reg red_parties c.murdered_red_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.murdered_red_share##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.murdered_white_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.murdered_white_share##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.murdered_red_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.murdered_red_share##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.murdered_white_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.murdered_white_share##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.murdered_red_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.murdered_red_share##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.murdered_white_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.murdered_white_share##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

esttab est* using "$tables/table_2.tex", append  booktabs   ///
	compress lines star(* .1 ** .05 *** .01) ///
	b(%9.3f) se(%9.3f) stats(N r2 ymean beta, labels("\textit{N}"  "\textit{R\textsuperscript{2}}" "Outcome mean" "Standardized effect size") ///
	fmt(0 2 2 2)) keep(1.post#c.murdered_red_share 1.post#c.murdered_white_share) coeflabels(1.post#c.murdered_red_share "Executed Reds $\times$ 1[Year $\geq$ 1917]" ///
	1.post#c.murdered_white_share "Executed Whites $\times$ 1[Year $\geq$ 1917]") nodepvars nomtitle nonumbers ///
	prehead("") refcat(1.post#c.murdered_red_share "\textbf{Panel B:} Executed", nolabel) ///
	postfoot("")
	
est clear

reg red_parties c.camp_red_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.camp_red_share##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.camp_red_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.camp_red_share##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg red_parties c.camp_red_share##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe red_parties c.camp_red_share##i.post year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, absorb(munig) vce(cluster munig)
estadd scalar beta
estadd ysumm

esttab est* using "$tables/table_2.tex", append  booktabs   ///
	compress lines star(* .1 ** .05 *** .01) ///
	b(%9.3f) se(%9.3f) stats(N r2 ymean beta, labels("\textit{N}"  "\textit{R\textsuperscript{2}}" "Outcome mean" "Standardized effect size") ///
	fmt(0 2 2 2)) keep(1.post#c.camp_red_share) coeflabels(1.post#c.camp_red_share "Prison camp deaths $\times$ 1[Year $\geq$ 1917]") nodepvars nomtitle nonumbers extracols(2 3 4) ///
	prehead("") refcat(1.post#c.camp_red_share "\textbf{Panel C:} Prison camp deaths", nolabel) ///
	postfoot("\bottomrule \end{tabular}")

********************************************************************************

* Figure 3
	
drop treat*	
	
levelsof year, local(level)
foreach l of local level {
		gen treat_`l'=0
		replace treat_`l'=dead if year==`l'
	}

tempfile t1 t2
parmby "reghdfe agrarian_party treat_1910 treat_1911 treat_1913 treat_1917 treat_1919 treat_1922 treat_1924 treat_1927 treat_1929 treat_1930 treat_1933 treat_1936, a(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)", lab saving(`"`t1'"',replace) idn(1) ids(Unadjusted)

preserve
clear all
set obs 1
gen year =1916
gen estimate = 0
gen parm ="treat_1916"
gen min95 =0
gen max95 =0
append using `t1'
keep if regexm(parm, "^treat*")
gen yearstr =substr(parm, -4,4)
destring yearstr, replace
sort yearstr

twoway  (rcap min95 max95 yearstr, lwidth(medium) ylabel(,format(%9.0f)) scheme(plotplain) xsize(6) ysize(4) xtitle(Year, size(small))  yline(0, lcolor(black)) xline(1916.5, lcolor(black))  xline(1918, lcolor(black)) ytitle(Regression coefficient) ///
xlabel(1910 1911 1913 1916 1917 1919 1922 1924 1927 1929 1930 1933 1936, angle(vertical) labsize(small)) graphregion(color(white)) legend(off) ///
subtitle("Panel A: Agrarian Party vote share", position(11))) (connected estimate yearstr, msize(medium) msymbol(circle) mcolor(black))
graph save "$figures/casualties_agrarian_party.gph", replace
	
restore	
	
drop treat*

levelsof year, local(level)
foreach l of local level {
		gen treat_`l'=0
		replace treat_`l'=dead if year==`l'
	}

tempfile t1 t2
parmby "reghdfe right_wing treat_1910 treat_1911 treat_1913 treat_1917 treat_1919 treat_1922 treat_1924 treat_1927 treat_1929 treat_1930 treat_1933 treat_1936, a(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)", lab saving(`"`t1'"',replace) idn(1) ids(Unadjusted)

preserve
clear all
set obs 1
gen year =1916
gen estimate = 0
gen parm ="treat_1916"
gen min95 =0
gen max95 =0
append using `t1'
keep if regexm(parm, "^treat*")
gen yearstr =substr(parm, -4,4)
destring yearstr, replace
sort yearstr

twoway  (rcap min95 max95 yearstr, lwidth(medium) ylabel(,format(%9.0f)) scheme(plotplain) xsize(6) ysize(4) xtitle(Year, size(small))  yline(0, lcolor(black)) xline(1916.5, lcolor(black))  xline(1918, lcolor(black)) ytitle(Regression coefficient) ///
xlabel(1910 1911 1913 1916 1917 1919 1922 1924 1927 1929 1930 1933 1936, angle(vertical) labsize(small)) graphregion(color(white)) legend(off) ///
subtitle("Panel B: Right-wing parties' vote share", position(11))) (connected estimate yearstr, msize(medium) msymbol(circle) mcolor(black))
graph save "$figures/casualties_right_wing.gph", replace
	
restore	

graph combine "$figures/casualties_agrarian_party.gph" "$figures/casualties_right_wing.gph", ///
	scheme(plotplain) cols(1) xsize(16) ysize(18)
graph export "$figures/figure_3.pdf", as(pdf) replace	
	
********************************************************************************

* Table 3

// Generate changes in inequality

gen gini = gini_1904 if post == 0 
replace gini = gini_1938 if post == 1

preserve

keep if gini != .
duplicates drop municipality post, force
	
est clear

reg gini c.dead##i.post i.munig i.post#(i.laanig c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe gini c.dead##i.post, absorb(munig post#laanig post#(c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg gini c.insurgency##i.post i.munig i.post#(i.laanig c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe gini c.insurgency##i.post, absorb(munig post#laanig post#(c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg gini c.whitedead##i.post i.munig i.post#(i.laanig c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe gini c.whitedead##i.post, absorb(munig post#laanig post#(c.gini_1904 c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg gini c.dead##i.post i.munig i.post#(i.laanig c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe gini c.dead##i.post if red_region == 1, absorb(munig post#laanig post#(c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg gini c.insurgency##i.post i.munig i.post#(i.laanig c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe gini c.insurgency##i.post if red_region == 1, absorb(munig post#laanig post#(c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg gini c.whitedead##i.post i.munig i.post#(i.laanig c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe gini c.whitedead##i.post if red_region == 1, absorb(munig post#laanig post#(c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg gini c.dead##i.post i.munig i.post#(i.laanig c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe gini c.dead##i.post if red_region == 0, absorb(munig post#laanig post#(c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg gini c.insurgency##i.post i.munig i.post#(i.laanig c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe gini c.insurgency##i.post if red_region == 0, absorb(munig post#laanig post#(c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg gini c.whitedead##i.post i.munig i.post#(i.laanig c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe gini c.whitedead##i.post if red_region == 0, absorb(munig post#laanig post#(c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

esttab est* using "$tables/table_3.tex", replace  mgroups("Entire country" "Red Finland" "White Finland",  pattern(1 0 0 1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) )  booktabs   ///
	compress lines star(* .1 ** .05 *** .01) ///
	b(%9.3f) se(%9.3f) stats(N r2 ymean beta, labels("\textit{N}"  "\textit{R\textsuperscript{2}}" "Outcome mean" "Standardized effect size") ///
	fmt(0 2 2 2)) keep(1.post#c.dead 1.post#c.insurgency 1.post#c.whitedead) coeflabels(1.post#c.dead "Civil war casualties $\times$ 1[Year $\geq$ 1917]" ///
	1.post#c.insurgency "Red casualties $\times$ 1[Year $\geq$ 1917]" 1.post#c.whitedead "White casualties $\times$ 1[Year $\geq$ 1917]") nodepvars nomtitle ///
	prehead(\begin{tabular}{l*{10}{c}} \toprule) ///
	postfoot(\bottomrule \end{tabular})			

restore

********************************************************************************
	
* Table 4
	
est clear

reg turnout c.dead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe turnout c.dead##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg turnout c.insurgency##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe turnout c.insurgency##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg turnout c.whitedead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe turnout c.whitedead##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg turnout c.dead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe turnout c.dead##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg turnout c.insurgency##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe turnout c.insurgency##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg turnout c.whitedead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe turnout c.whitedead##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg turnout c.dead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe turnout c.dead##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg turnout c.insurgency##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe turnout c.insurgency##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg turnout c.whitedead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe turnout c.whitedead##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

esttab est* using "$tables/table_4.tex", replace  mgroups("Entire country" "Red Finland" "White Finland",  pattern(1 0 0 1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) )  booktabs   ///
	compress lines star(* .1 ** .05 *** .01) ///
	b(%9.3f) se(%9.3f) stats(N r2 ymean beta, labels("\textit{N}"  "\textit{R\textsuperscript{2}}" "Outcome mean" "Standardized effect size") ///
	fmt(0 2 2 2)) keep(1.post#c.dead 1.post#c.insurgency 1.post#c.whitedead) coeflabels(1.post#c.dead "Civil war casualties $\times$ 1[Year $\geq$ 1917]" ///
	1.post#c.insurgency "Red casualties $\times$ 1[Year $\geq$ 1917]" 1.post#c.whitedead "White casualties $\times$ 1[Year $\geq$ 1917]") nodepvars nomtitle ///
	prehead(\begin{tabular}{l*{10}{c}} \toprule) ///
	postfoot(\bottomrule \end{tabular})			

********************************************************************************

* Table 5

est clear

reg share_disqualified c.dead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe share_disqualified c.dead##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg share_disqualified c.insurgency##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe share_disqualified c.insurgency##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg share_disqualified c.whitedead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m), beta
scalar beta = r(PT)[5,6]
eststo: reghdfe share_disqualified c.whitedead##i.post, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg share_disqualified c.dead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe share_disqualified c.dead##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg share_disqualified c.insurgency##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe share_disqualified c.insurgency##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg share_disqualified c.whitedead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 1, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe share_disqualified c.whitedead##i.post if red_region == 1, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg share_disqualified c.dead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe share_disqualified c.dead##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg share_disqualified c.insurgency##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe share_disqualified c.insurgency##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

reg share_disqualified c.whitedead##i.post i.munig i.year#(i.laanig c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m) if red_region == 0, beta
scalar beta = r(PT)[5,6]
eststo: reghdfe share_disqualified c.whitedead##i.post if red_region == 0, absorb(munig year#laanig year#(c.gini_1904 c.pop_present_all c.lat c.lon c.slope_mean c.altitude_m)) vce(cluster munig)
estadd scalar beta
estadd ysumm

esttab est* using "$tables/table_5.tex", replace  mgroups("Entire country" "Red Finland" "White Finland",  pattern(1 0 0 1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) )  booktabs   ///
	compress lines star(* .1 ** .05 *** .01) ///
	b(%9.3f) se(%9.3f) stats(N r2 ymean beta, labels("\textit{N}"  "\textit{R\textsuperscript{2}}" "Outcome mean" "Standardized effect size") ///
	fmt(0 2 2 2)) keep(1.post#c.dead 1.post#c.insurgency 1.post#c.whitedead) coeflabels(1.post#c.dead "Civil war casualties $\times$ 1[Year $\geq$ 1917]" ///
	1.post#c.insurgency "Red casualties $\times$ 1[Year $\geq$ 1917]" 1.post#c.whitedead "White casualties $\times$ 1[Year $\geq$ 1917]") nodepvars nomtitle ///
	prehead(\begin{tabular}{l*{10}{c}} \toprule) ///
	postfoot(\bottomrule \end{tabular})			
